/*
*func: return url param value
*{paramName} url param key
*/
function getParam(paramName)
{
	var paramValue = "";
	var isFound = false;
	if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=")>1)
	{
		arrSource = unescape(this.location.search).substring(1,this.location.search.length).split("&");
        //arrSource = this.location.search.substring(1,this.location.search.length).split("&");
		var i = 0;
		while (i < arrSource.length && !isFound)
		{
			if (arrSource[i].indexOf("=") > 0)
			{
				 if (arrSource[i].split("=")[0].toLowerCase()==paramName.toLowerCase())
				 {
					paramValue = arrSource[i].split("=")[1];
					isFound = true;
				 }
			}
			i++;
		}   
	}
	return paramValue;
}

/*
*func: verify that customer id, return true of false
*{idCard} id number
*/
function IdCardValidate(idCard) {
    function isValidityBrithBy18IdCard(idCard18){  
        var year =  idCard18.substring(6,10);  
        var month = idCard18.substring(10,12);  
        var day = idCard18.substring(12,14);  
        var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));
        if(temp_date.getFullYear()!=parseFloat(year)  
              ||temp_date.getMonth()!=parseFloat(month)-1  
              ||temp_date.getDate()!=parseFloat(day)){  
                return false;  
        }else{  
            return true;  
        }  
    }  

    function isValidityBrithBy15IdCard(idCard15){  
        var year =  idCard15.substring(6,8);  
        var month = idCard15.substring(8,10);  
        var day = idCard15.substring(10,12);  
        var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));
        if(temp_date.getYear()!=parseFloat(year)  
              ||temp_date.getMonth()!=parseFloat(month)-1  
              ||temp_date.getDate()!=parseFloat(day)){  
                return false;  
        }else{  
            return true;  
        }  
    }  

    function isTrueValidateCodeBy18IdCard(a_idCard) {
        var Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 ];
        var ValideCode = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ];
        var sum = 0; 
        if (a_idCard[17].toLowerCase() == 'x') {  
            a_idCard[17] = 10;
        }  
        for ( var i = 0; i < 17; i++) {  
            sum += Wi[i] * a_idCard[i];
        }  
        valCodePosition = sum % 11;
        if (a_idCard[17] == ValideCode[valCodePosition]) {  
            return true;  
        } else {  
            return false;  
        }  
    } 	
    
    if (idCard.length == 15) {  
        return isValidityBrithBy15IdCard(idCard);  
    } else if (idCard.length == 18) {  
        var a_idCard = idCard.split("");
        if(isValidityBrithBy18IdCard(idCard)&&isTrueValidateCodeBy18IdCard(a_idCard)){ 
            return true;  
        }else {   
            return false;  
        }  
    } else {  
        return false;  
    }  
}


/*
*func: Verify that the phone number, return true of false
*{value} mobile phone number
*/
function isMob(value){
    var regex = /^0?(13[0-9]|17[07]|15[012356789]|18[012356789]|14[57])[0-9]{8}$/;
    return regex.test(value);
}